
# s=[int(i) for i in list(input().split())]
s=list(map(int,input().split()))
# print(type(s))
# print(s)

sStrList=[str(ss) for ss in s]
asn=0
sStr="".join(sStrList)
res=""
for i in range(0,len(s)):
    res=sStr.replace("111","x").replace("11","x").replace("1","x")

for r in res:
    if r=="x":
        asn=asn+1
print(asn)


